﻿@{
    Layout = "_LayoutBlank";
    ViewData["Title"] = "LPlayer";
}
@section Styles{
<link rel="stylesheet" href="~/css/player.css" asp-append-version="true" />
}
<div class="window">
    <div class="container">
        <!-- style="transform:translateX(-33.3333%);-webkit-transform:translateX(-33.3333%);" -->
        <div class="search"></div>
        <div class="lplayer-container">
            <div class="lplayer"></div>
            <!-- 分享按钮 -->
            <div class="share-button">
                <svg t="1652878712809" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1928" width="128" height="128"><path d="M512 939.804444c-57.612929 0-113.570909-11.274343-166.322424-33.616161-50.889697-21.514343-96.504242-52.337778-135.809293-91.539394C170.666667 775.447273 139.843232 729.729293 118.328889 678.839596 96.193939 626.191515 84.816162 570.233535 84.816162 512.620606s11.274343-113.570909 33.616161-166.322424c21.514343-50.889697 52.337778-96.504242 91.539394-135.809293 39.201616-39.201616 84.919596-70.025051 135.809293-91.539394 52.648081-22.238384 108.606061-33.616162 166.322424-33.616162h1.034344l-0.103435 57.923233h-0.930909c-98.676364 0-191.353535 38.374141-261.068282 108.192323-69.818182 69.818182-108.295758 162.495354-108.295758 261.171717s38.374141 191.353535 108.192323 261.068283c69.714747 69.818182 162.495354 108.192323 261.068283 108.192323 98.572929 0 191.250101-38.374141 261.068283-108.088889C842.78303 704.077576 881.260606 611.400404 881.260606 512.827475h57.923232c0 57.612929-11.377778 113.570909-33.616161 166.21899-21.514343 50.889697-52.337778 96.504242-91.539394 135.705858s-84.919596 69.921616-135.705859 91.43596c-52.751515 22.341818-108.606061 33.616162-166.322424 33.616161zM938.149495 352.711111h-57.923232V145.73899H672.530101v-57.923232H938.149495V352.711111z m0 0" p-id="1929" fill="#ffffff"></path><path d="M888.371717 96.012929l40.96 40.96L560.484848 505.806869l-40.96-40.96L888.371717 96.012929z m0 0" p-id="1930" fill="#ffffff"></path></svg>
            </div>
        </div>
        <div class="list"></div>
    </div>
</div>

@section Scripts{
<script>
    let domain = '@Html.Raw(ViewData["Domain"])';
    let musicShare = @Html.Raw(ViewData["MusicShare"]);
</script>
<script src="~/lib/LPlayer/LPlayer.min.js" asp-append-version="true"></script>
<script src="~/lib/LPlayer/SList.min.js" asp-append-version="true"></script>
<script src="~/js/Pages/Player.js" asp-append-version="true"></script>
<script>
    var shareButton = document.querySelector('.share-button');
    shareButton.addEventListener('click', function(e){
        let audio = player.list.audios[player.list.index]; // 当前播放歌曲
        let downloadInfo = audio.url.match(/MUSIC_\d+/)[0];
        downloadInfo = downloadInfo.match(/\d+/)[0];
        let shareUrl = `${domain}/?name=${audio.name}&artist=${audio.artist}&info=${downloadInfo}`;
        // 模拟复制 begin
        let area = document.createElement('textarea');
        area.innerText = shareUrl;
        document.body.appendChild(area);
        area.select();
        document.execCommand('Copy');
        document.body.removeChild(area);
        // 模拟复制 end
        alert('分享歌曲连接，已复制到粘贴板！');
    });
</script>
}